<?php
class Game {
    private $noMoneyState;
    private $hasMoneyState;
    private $soldSate;
    private $soldOutState;

    private $state;
    private $count = 10;

    public function __construct()
    {
        $this->noMoneyState = new NoMoney($this);
        $this->hasMoneyState= new HasMoney($this);
        $this->soldOutState = new SoldOut($this);
        $this->soldSate     = new Sold($this);
        if ($this->count > 0)
        {
            $this->state = $this->getNoMoneyState();
        }
    }

    public function insertMoney($money)
    {
        $this->state->insertMoney($money);
    }
    public function turn()
    {
        $this->state->turn();
    }
    public function reject() {
        $this->state->reject();
    }
    public function get() {
        $this->state->get();
    }
    public function getNoMoneyState() {
        return $this->noMoneyState;
    }
    public function getHasMoneyState() {
        return $this->hasMoneyState;
    }
    public function getSoldState() {
        return $this->soldSate;
    }
    public function getSoldOutState() {
        return $this->soldOutState;
    }

    public function setState(State $state)
    {
        $this->state = $state;
    }
}